<template>
	<view class="">
		<uni-popup ref="popup" type="bottom" background-color="#fff" borderRadius="20rpx 20rpx 0 0">
			<view class="popup-wrap">
				<view class="popup-header">
					<view class="popup-header-title">
						<text>{{title}}</text>
					</view>
					<view class="popup-header-close" @click="close">
						<image :src="$img_path('/home/icon-close.png')" mode="widthFix"></image>
					</view>
				</view>
				<view class="popup-content">
					<view class="popup-content-list">
						<scroll-view scroll-y="true" style="height: 100%;">
							<view class="popup-content-list-item" v-for="(item, index) in list" :key="index" @click="selectSkuItem(item)">
								<view class="">
									<text>{{ item.name }}</text>
								</view>
								<view class="icon">
									<image v-if="item.id == skuItem" :src="$img_path('/course/pay_checkbox1.png')" mode="widthFix"></image>
									<image v-else :src="$img_path('/course/pay_checkbox2.png')" mode="widthFix"></image>
								</view>
							</view>
							<view class="textarea-box" v-if="type==1">
								<textarea v-model="textarea" placeholder="请输入取消的原因" :maxlength="200" class="textarea"></textarea>
							</view>
						</scroll-view>
					</view>
					<view class="popup-btns" v-if="type==1">
						<view class="popup-btn" @click="close">
							<text>我再想想</text>
						</view>
						<view class="popup-btn confirm-btn common-btn-bg-color" @click="confirm">
							<text>确认取消</text>
						</view>
					</view>
					<view class="popup-btns" v-if="type==2">
						<view style="width: 100%;" class="popup-btn confirm-btn common-btn-bg-color" @click="confirm">
							<text>确认</text>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		props: {
			title:{
				type:String,
				default:''
			},
			type:{
				type:Number,
				default:'',//1取消，2退款
			}
		},
		data() {
			return {
				skuItem: '',
				list: [],
				textarea: ""
			}
		},
		mounted() {
			
		},
		methods: {
			
			open() {
				this.$refs.popup.open()
			},
			
			close() {
				this.$refs.popup.close()
			},
			
			selectSkuItem(item) {
				this.skuItem = item.id
			},
			
			confirm() {
				let info = {
					
				}
				// this.close()
				// this.$emit('confirm')
			}
		}
	}
</script>

<style scoped lang="scss">
	.popup-wrap {
		padding: 36rpx 22rpx 68rpx 22rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		position: relative;
		image {
			width: 100%;
			height: 100%;
		}
		
		view {
			box-sizing: border-box;
		}
	}
	
	.popup-header {
		display: flex;
		align-items: center;
	}
	
	.popup-header-title {
		flex: 1;
		text-align: center;
		font-weight: bold;
		font-size: 36rpx;
		color: #333333;
	}
	
	.popup-header-close {
		// position: absolute;
		width: 32rpx;
		height: 32rpx;
	}
	
	.popup-content {
		margin-top: 46rpx;
		flex: 1;
		display: flex;
		flex-direction: column;
	}
	
	.popup-content-list {
		// height: 950rpx;
		padding-bottom: 164rpx;
	}
	
	.popup-content-list-item {
		margin-bottom: 32rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-weight: 400;
		font-size: 30rpx;
		color: #000000;
		background: #FFF;
		
		.icon {
			width: 40rpx;
			height: 40rpx;
		}
	}
	
	.textarea {
		width: 706rpx;
		height: 208rpx;
		background: #F8F8F8;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		padding: 18rpx 22rpx;
		box-sizing: border-box;
	}
	
	.popup-btns {
		width: 100%;
		height: 164rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -4rpx 8rpx 2rpx rgba(0,0,0,0.05);
		position: absolute;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		padding: 12rpx 20rpx;
		padding-bottom: 60rpx;
	}
	
	.popup-btn {
		width: 300rpx;
		height: 96rpx;
		background: #F8F8F8;
		border-radius: 80rpx 80rpx 80rpx 80rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #999999;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.confirm-btn {
		color: #FFF;
	}
</style>